
<template>
  <base-page-view class-name="page-container bills">
    <view v-if="aaa&&bbb" class="bills_tips">
      <image src="/static/images/commission/shopping_tip.png" class="shopping_tip" />
      <view v-if="isShowRealname" class="tips_center">{{ remark }}</view>
      <view v-if="!isShowRealname" class="tips_center">温馨提示：您还未实名认证,无法发放收益,请前往<span class="realName" @click="toRealName">实名认证</span></view>
      <image src="/static/images/commission/tips_delete.png" class="tips_delete" @click="bbb=!bbb" />
    </view>
    <view v-for="(item,index) in listData" :key="index" class="bills_list">
      <view class="bills_head">
        <view>
          <view class="title">{{ item.month.substring(0,4)+'年'+item.month.substring(4,6)+'月份发放' }}</view>
          <view class="date">{{ item.withdrawTime }}</view>
        </view>
        <view v-if="item.status===1" class="success">
          发放成功
        </view>
        <view v-else class="fail">
          发放失败
        </view>
      </view>
      <view class="bills_details">
        <view class="details">
          <view>应发(元)</view>
          <view>{{ item.amount | formatMoney }}</view>
        </view>
        <view class="details">
          <view>扣税（元）</view>
          <view>{{ item.fee | formatMoney }}</view>
        </view>
        <view class="details">
          <view>实发（元）</view>
          <view>{{ item.actualAmount | formatMoney }}</view>
        </view>
      </view>
      <view v-if="item.showDeatil" class="bills_btn">
        <view @click="$navigateTo('/pagesCommission/earnings/billsDetails?id='+item.withdrawId+'&time='+item.month)">
          点击查看明细
          <image src="/static/images/mine/list_more.png" class="bills_list_more" />
        </view>
      </view>
    </view>

    <view v-if="listData.length<1" class="empty_view">
      <image src="/static/images/commission/commission-empty.png" class="empty_img" />
      <view class="tit">暂无任何内容</view>
    </view>
    <view v-if="nomore && listData.length>0" class="nomore">暂无更多数据~</view>
  </base-page-view>
</template>

<script>
import './bills.scss'
export default {
  components: {
  },
  data() {
    return {
      pageSize: 10,
      pageNo: 1,
      listData: [],
      nomore: false,
      startTime: 1483200000000,
      endTime: '',
      remark: '',
      tipsShow: true,
      isShowRealname: false,
      bbb: true
    }
  },
  computed: {
    aaa() {
      if (this.isShowRealname) {
        if (this.tipsShow && this.listData.length > 0) {
          return true
        } else {
          return false
        }
      } else {
        return true
      }
    }
  },
  created() {
  },
  onLoad(option) {
    this.endTime = Math.ceil(new Date().getTime())
    this.getList()
    if (this.$store.state.setting.status === 3) {
      this.isShowRealname = true
    } else {
      this.isShowRealname = false
    }
  },
  onPullDownRefresh() {
    this.pageNo = 1
    this.listData = []
    this.nomore = false
    this.getList()
  },
  onReachBottom() {
    if (this.nomore) return
    this.pageNo += 1
    this.getList()
  },
  onShow() {
  },
  methods: {
    toRealName() {
      uni.removeStorageSync('realName')
      this.$navigateTo('/pagesMine/certification/index')
    },
    async getList() {
      const res = await this.$api.commissionApi.getUserWithdrawList({
        userId: this.$store.state.userInfo.uid,
        pageSize: this.pageSize,
        pageNo: this.pageNo,
        startTime: this.startTime,
        endTime: this.endTime
      })
      if (res.code === '000000') {
        setTimeout(function() {
          uni.stopPullDownRefresh()
        }, 500)
        this.listData = this.listData.concat(res.data.userWithdrawList)
        if (res.data.userWithdrawList.length < this.pageSize) {
          this.nomore = true
        }
        this.remark = res.data.remark
      }
    }
  }
}
</script>
